/*
 * Copyright (C) 2018 guomw.Inc. All rights reserved.
 * 项目名称： report-manage
 * 文件名称： SystemManagerRepository.java
 * Date：18-11-5 上午10:54
 * Author: guomw
 */

package com.guomw.report.service.repository.system;

import com.guomw.report.service.entity.SystemManager;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

/**
 * 系统管理员Repository
 * @author guomw
 * @date 2018/9/17
 */
@Repository
public interface SystemManagerRepository extends JpaRepository<SystemManager,Integer>,JpaSpecificationExecutor<SystemManager> {

    /**
     * 更新启用状态
     * @param userId
     * @param enable
     * @return
     */
    @Query("update SystemManager m set m.enable=?2 where m.userId=?1")
    @Modifying(clearAutomatically = true)
    @Transactional(rollbackFor = RuntimeException.class)
    int updateEnableById(Integer userId,boolean enable);
}
